package com.shine.minepressure.ui;

import android.os.Bundle;
import android.os.CountDownTimer;
import android.view.View;

import com.shine.minepressure.BR;
import com.shine.minepressure.R;
import com.shine.minepressure.app.Constants;
import com.shine.minepressure.base.BaseActivity;
import com.shine.minepressure.databinding.ActivitySplashBinding;
import com.shine.minepressure.ui.chart.ChartActivity;
import com.shine.minepressure.ui.chart.ChartListActivity;
import com.shine.minepressure.ui.login.LoginNewActivity;
import com.shine.minepressure.ui.viewModel.SplashActivityViewModel;


public class SplashActivity extends BaseActivity<ActivitySplashBinding, SplashActivityViewModel> {
    private long countDownTime = 1000;
    private CountDownTimer countDownTimer;

    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_splash;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public SplashActivityViewModel initViewModel() {
        return new SplashActivityViewModel(this);
    }

    @Override
    public int appTheme() {
        return Constants.THEME_FULL;
    }

    @Override
    public void initData() {
        super.initData();
        setStatusBar();

        setCountDownTime(true);
        countDownTimer.start();


    }

    @Override
    public void onClick(View view) {

    }

    @Override
    protected void onRestart() {
        super.onRestart();
        setCountDownTime(true);
        countDownTimer.start();
    }

    private void setCountDownTime(boolean isFirst) {
        countDownTimer = new CountDownTimer(countDownTime, 1000) {
            @Override
            public void onTick(long l) {
            }

            @Override
            public void onFinish() {
//                switchActivityAndFinish(ChartListActivity.class);
                switchActivityAndFinish(LoginNewActivity.class);
            }
        };
    }

}
